<%@ page language="java" contentType="text/html;charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>">
		<title><s:text name="sys.app_title" />
		</title>
		<%@include file="../include/contentheader.jsp"%>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="js/app.js"></script>
		<link rel="stylesheet" type="text/css" href="css/main.css" />
		<link rel="StyleSheet" type="text/css" href="css/dtree.css" />
		<script type="text/javascript" src="js/dtree.js"></script>
		<script type="text/javascript" src="dwr/util.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/engine.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/departmentDwrJs.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/findStaff.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/findStaffByDepid.js"></script>
		<script type="text/javascript" src="js/dep.js"></script>
		<link rel="StyleSheet" href="css/dep.css" type="text/css" />
		<script type="text/javascript">
			function zzzz(pid,sid){
				window.returnValue=pid+','+sid;
				window.close();
			}
			function doClose(pid){
				findStaffByDepid.staffBydepid(pid,function(staffList){
					var inner = "";
						for(var i = 0;i < staffList.length;i++){
							inner += "<tr class='dataRow'><td>"+staffList[i].staname+"</td><td><input type='button' value='选择' onclick=zzzz(\'"+pid+"\',\'"+staffList[i].staname+"\')></td></tr>"
						}
					$('tbody#StaffManager').html(inner);
				});
			}
		</script>
	</head>

	<body onload="buildTree()">
	<input type="button" onclick="window.close()" value="取消" />
		<div class="mainContainer">
			<div class="headerTitle">
				请先选择上级部门
			</div>
			<div class="dtreeDiv" id="myTree" style="width: 200px;height: 400px;float:left;display: block;overflow: auto;" onclick="">
				<script type="text/javascript">
	var myTree = document.getElementById("myTree");
	d = new dTree('d');
	var inner;
	function buildTree() {
		departmentDwrJs.getAllDepartment(function(departmentList) {
			d.add(-1, -2, '广元电业局');
			for ( var i = 0; i < departmentList.length; i++) {
					d.add(departmentList[i].depid,departmentList[i].depparentid,
							"<b style=\'cursor:pointer\' onclick=doClose(\'"+departmentList[i].depid+"\')>"+departmentList[i].depname+"</b>");
			}
			inner = d.toString();
			showBuildTree();
			$('b').parent().attr('href','javascript:void(0)');
		});
	}
	function showBuildTree() {
		myTree.innerHTML = inner;
	}
</script>
			</div>
			<div class="dtreeDiv" style="width: 200px;height: 250px;float:left;display: block;padding: 0px;overflow: auto;">
				<table class="gridTable" border="0" cellspacing="0" cellpadding="0" style="margin:0px;">
					<tr class="operatorAction">
						<td>
						</td>
					</tr>
					<tr>
						<td class="gridData">
		
						<table class="dataTable" border="0" cellpadding="0" cellspacing="1">
	     				     <tr class="dataHeader">
	          	<!-- 数据表头 -->
	    			        <td width="50%">员工姓名</td>
	    			        <td width="40%">选择</td>
	    		      </tr>
	    		      <tbody id="StaffManager">
	    		      	
	    		      </tbody>
	    		  </table>
	    		  </td>
	    		  </tr>
	    		  </table>
			</div>
		</div>
	</body>
</html>